﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:m="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation"
             xmlns:w="http://schemas.jelle.druyts.net/2010/xaml/presentation"
             xmlns:svc="clr-namespace:Schedulr.Views.Controls"
             x:Class="Schedulr.Views.Controls.PictureDetails"
             d:DesignHeight="500"
             d:DesignWidth="500"
             mc:Ignorable="d">
    <UserControl.Resources>
        <w:EnumToBooleanConverter x:Key="enumConverter" />
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Auto">
            <StackPanel Margin="5">
                <Expander Header="Online" Margin="0,0,0,10" Visibility="{Binding OnlineDetailsVisibility}">
                    <StackPanel>
                        <Label Content="Web Page" />
                        <TextBlock><w:ExternalHyperlink Foreground="{DynamicResource InfoFontBrush}" NavigateUri="{Binding Path=Picture.WebUrl}" ToolTip="{Binding Path=Picture.WebUrl}"><Run Text="{Binding Path=Picture.Title}" /></w:ExternalHyperlink></TextBlock>
                        <Label Content="Date Uploaded" />
                        <TextBlock Foreground="{DynamicResource InfoFontBrush}" Text="{Binding Path=Picture.DateUploaded, StringFormat=f}" />
                    </StackPanel>
                </Expander>
                <Expander Header="Details" Margin="0,0,0,0">
                    <StackPanel>
                        <Grid Visibility="{Binding FileDetailsVisibility}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <StackPanel Grid.Column="0">
                                <Label Content="_Path" Target="{Binding ElementName=fileNameTextBox, Mode=OneWay}" />
                                <TextBox IsReadOnly="True" x:Name="fileNameTextBox" Text="{Binding Path=Picture.FileName, Mode=OneWay}" />
                            </StackPanel>
                            <StackPanel Grid.Column="1" Margin="5,0,0,0">
                                <Label Content="_Size" Target="{Binding ElementName=fileSizeTextBox, Mode=OneWay}" />
                                <TextBox IsReadOnly="True" x:Name="fileSizeTextBox" Text="{Binding Path=FileSizeDescription, Mode=OneWay}">
                                    <TextBox.Style>
                                        <Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
                                            <Style.Triggers>
                                                <DataTrigger Binding="{Binding FileSizeErrorVisibility}" Value="Visible">
                                                    <Setter Property="BorderBrush" Value="{DynamicResource ErrorForegroundBrush}" />
                                                    <Setter Property="Foreground" Value="{DynamicResource ErrorForegroundBrush}" />
                                                    <Setter Property="ToolTip" Value="The file is larger than the maximum file size you are allowed to upload." />
                                                </DataTrigger>
                                            </Style.Triggers>
                                        </Style>
                                    </TextBox.Style>
                                </TextBox>
                            </StackPanel>
                        </Grid>
                        <Label Content="_Title" Target="{Binding ElementName=titleTextBox, Mode=OneWay}" />
                        <TextBox x:Name="titleTextBox" Text="{Binding Path=Picture.Title, Mode=TwoWay}" IsReadOnly="{Binding IsReadOnly}" />
                        <Label Content="_Description" Target="{Binding ElementName=descriptionTextBox, Mode=OneWay}" />
                        <TextBox x:Name="descriptionTextBox" Text="{Binding Path=Picture.Description, Mode=TwoWay}" Height="100" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" TextWrapping="Wrap" IsReadOnly="{Binding IsReadOnly}" />
                        <Label Content="{Binding TagsLabel}" Target="{Binding ElementName=tagsTextBox, Mode=OneWay}" />
                        <TextBox x:Name="tagsTextBox" Text="{Binding Path=Picture.Tags, Mode=TwoWay}" IsReadOnly="{Binding IsReadOnly}" />
                    </StackPanel>
                </Expander>
                <Expander Header="Settings" Margin="0,10,0,0">
                    <WrapPanel>
                        <StackPanel Margin="0,0,20,0">
                            <Label Content="_Visibility" Target="{Binding ElementName=visibilityIsPublicCheckBox, Mode=OneWay}" />
                            <CheckBox x:Name="visibilityIsPublicCheckBox" Content="Public" IsChecked="{Binding Path=Picture.VisibilityIsPublic, Mode=TwoWay}" IsEnabled="{Binding IsEditable}" />
                            <CheckBox x:Name="visibilityIsFamilyCheckBox" Content="Family" IsChecked="{Binding Path=Picture.VisibilityIsFamily, Mode=TwoWay}" IsEnabled="{Binding IsEditable}" />
                            <CheckBox x:Name="visibilityIsFriendCheckBox" Content="Friends" IsChecked="{Binding Path=Picture.VisibilityIsFriend, Mode=TwoWay}" IsEnabled="{Binding IsEditable}" />
                        </StackPanel>
                        <StackPanel Margin="0,0,20,0">
                            <Label Content="_Safety" Target="{Binding ElementName=safetyIsNoneRadioButton, Mode=OneWay}" />
                            <RadioButton x:Name="safetyIsNoneRadioButton" GroupName="PhotoSafety" Content="Default" IsChecked="{Binding Path=Picture.Safety, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=None}" IsEnabled="{Binding IsEditable}" />
                            <RadioButton x:Name="safetyIsSafeRadioButton" GroupName="PhotoSafety" Content="Safe" IsChecked="{Binding Path=Picture.Safety, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Safe}" IsEnabled="{Binding IsEditable}" />
                            <RadioButton x:Name="safetyIsModerateRadioButton" GroupName="PhotoSafety" Content="Moderate" IsChecked="{Binding Path=Picture.Safety, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Moderate}" IsEnabled="{Binding IsEditable}" />
                            <RadioButton x:Name="safetyIsRestrictedRadioButton" GroupName="PhotoSafety" Content="Restricted" IsChecked="{Binding Path=Picture.Safety, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Restricted}" IsEnabled="{Binding IsEditable}" />
                        </StackPanel>
                        <StackPanel Margin="0,0,20,0">
                            <Label Content="Ty_pe" Target="{Binding ElementName=contentTypeIsNoneRadioButton, Mode=OneWay}" Foreground="{DynamicResource InputFontColor}" />
                            <RadioButton x:Name="contentTypeIsNoneRadioButton" GroupName="ContentType" Content="Default" IsChecked="{Binding Path=Picture.ContentType, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=None}" IsEnabled="{Binding IsEditable}" />
                            <RadioButton x:Name="contentTypeIsPhotoRadioButton" GroupName="ContentType" Content="Photo" IsChecked="{Binding Path=Picture.ContentType, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Photo}" IsEnabled="{Binding IsEditable}" />
                            <RadioButton x:Name="contentTypeIsScreenshotRadioButton" GroupName="ContentType" Content="Screenshot" IsChecked="{Binding Path=Picture.ContentType, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Screenshot}" IsEnabled="{Binding IsEditable}" />
                            <RadioButton x:Name="contentTypeIsOtherRadioButton" GroupName="ContentType" Content="Other" IsChecked="{Binding Path=Picture.ContentType, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Other}" IsEnabled="{Binding IsEditable}" />
                        </StackPanel>
                        <StackPanel Margin="0,0,20,0">
                            <Label Content="_License" Target="{Binding ElementName=licenseComboBox, Mode=OneWay}" Foreground="{DynamicResource InputFontColor}" />
                            <ComboBox x:Name="licenseComboBox" IsEnabled="{Binding IsEditable}">
                                <ComboBoxItem x:Name="licenseIsNoneRadioButton" Content="Default" IsSelected="{Binding Path=Picture.License, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=None}" IsEnabled="{Binding IsEditable}" />
                                <ComboBoxItem x:Name="licenseIsAllRightsReservedRadioButton" Content="None (All rights reserved)" IsSelected="{Binding Path=Picture.License, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=AllRightsReserved}" IsEnabled="{Binding IsEditable}" />
                                <ComboBoxItem x:Name="licenseIsAttributionNoncommercialShareAlikeCC" Content="Attribution-NonCommercial-ShareAlike Creative Commons" IsSelected="{Binding Path=Picture.License, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=AttributionNoncommercialShareAlikeCC}" IsEnabled="{Binding IsEditable}" />
                                <ComboBoxItem x:Name="licenseIsAttributionNoncommercialCC" Content="Attribution-NonCommercial Creative Commons" IsSelected="{Binding Path=Picture.License, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=AttributionNoncommercialCC}" IsEnabled="{Binding IsEditable}" />
                                <ComboBoxItem x:Name="licenseIsAttributionNoncommercialNoDerivativesCC" Content="Attribution-NonCommercial-NoDerivs Creative Commons" IsSelected="{Binding Path=Picture.License, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=AttributionNoncommercialNoDerivativesCC}" IsEnabled="{Binding IsEditable}" />
                                <ComboBoxItem x:Name="licenseIsAttributionCC" Content="Attribution Creative Commons" IsSelected="{Binding Path=Picture.License, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=AttributionCC}" IsEnabled="{Binding IsEditable}" />
                                <ComboBoxItem x:Name="licenseIsAttributionShareAlikeCC" Content="Attribution-ShareAlike Creative Commons" IsSelected="{Binding Path=Picture.License, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=AttributionShareAlikeCC}" IsEnabled="{Binding IsEditable}" />
                                <ComboBoxItem x:Name="licenseIsAttributionNoDerivativesCC" Content="Attribution-NoDerivs Creative Commons" IsSelected="{Binding Path=Picture.License, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=AttributionNoDerivativesCC}" IsEnabled="{Binding IsEditable}" />
                            </ComboBox>
                        </StackPanel>
                    </WrapPanel>
                </Expander>
                <Expander Header="{Binding Path=Sets.Description}" Margin="0,10,0,0">
                    <ListBox ItemsSource="{Binding Path=Sets.Items}" Style="{Binding FlickrCollectionListStyle}" IsEnabled="{Binding IsEditable}" />
                </Expander>
                <Expander Header="{Binding Path=Groups.Description}" Margin="0,10,0,0">
                    <ListBox ItemsSource="{Binding Path=Groups.Items}" Style="{Binding FlickrCollectionListStyle}" IsEnabled="{Binding IsEditable}" />
                </Expander>
                <Expander Header="Location" Margin="0,10,0,0">
                    <StackPanel Orientation="Vertical">
                        <ItemsControl ItemsSource="{Binding LocationCommands}" Visibility="{Binding LocationCommandsVisibility}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <WrapPanel Orientation="Horizontal" />
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Button Content="{Binding Name}" ToolTip="{Binding Description}" Command="{Binding}" Margin="0,5,5,0" />
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                        <Grid Margin="0,10,0,0" HorizontalAlignment="Left">
                            <TextBlock Text="No location defined" />
                            <svc:GeoLocationMap Visibility="{Binding Path=LocationVisibility}" Location="{Binding Path=Picture.Location, Mode=TwoWay}" IsReadOnly="True" Height="300" Width="400" />
                        </Grid>
                    </StackPanel>
                </Expander>
            </StackPanel>
        </ScrollViewer>
        <Border Grid.Row="1" Style="{DynamicResource BorderStyle}" Background="Transparent" Padding="5" Margin="5" Visibility="{Binding InfoMessageVisibility}">
            <TextBlock FontStyle="Italic" Foreground="{DynamicResource InfoFontBrush}" HorizontalAlignment="Right" Margin="0,0,10,0" Text="{Binding InfoMessage}" />
        </Border>
    </Grid>
</UserControl>